#include "LoadImgTask.h"
LoadImgTask::LoadImgTask(char* body, int client_fd, int len, int shmid, int msgid) :BaseTask(body, client_fd, len, shmid, msgid)
{

}

void LoadImgTask::working()
{
	SAVEIMG_REQ date = { 0 };
	//拷贝解析数据
	memcpy(&date, body, sizeof(SAVEIMG_REQ));
	ImgData data = date.imgdata;
    // 安全操作map
    char name[100];
    snprintf(name, sizeof(name), "%d%s", data.user_id, data.img_name);
    {
        std::lock_guard<std::mutex> lock(img_data_mutex);
        img_data[name][data.index] = data;  // 受保护的操作
    }
    cout << "存入map index" << data.index << endl;

}

